<?php 
	//timer pengecekan load page...
	include("inc/timer.php");
	$_start_timer = get_microtime();
	 
	//check protect1 jika session da tidak valid, balikin ke index.php
	//jika valid y biarin saja
	
	require_once("protect1.php");
	require_once("inc/connect.php");
	require_once("inc/settings.php");
	require_once("inc/function-html.php");
	
	$_username = $reg_uname;
	$_semester = $_global_settings['semester']->value;
	$_tahun_ajaran = $_global_settings['tahun_ajaran']->value;
	$_level_settings = getLevelSettings($reg_level, $pdo);

	//$sql = "SELECT nama FROM biodata WHERE nrp = :reg_uname ";
	//$stmt = $pdo->prepare($sql);
	//$stmt->execute(array(':reg_uname' => $reg_uname )) or die("ERROR: " . implode(":", $stmt->errorInfo())); //reg jurusan dari protect1.php
	//$_data = $stmt->fetch(PDO::FETCH_OBJ);

?>
<!DOCTYPE html>
<html>
<head>
<title>Student Home !</title>
<link rel="stylesheet" type="text/css" href="css/reset_main.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<style type="text/css">
	body{ behavior:url(cssHoverFix.htc);}
	#div a { normal state }
	#div a:hover { alternative state }
</style>
</head>
<body>	
	<header id="main">
		<table id="header">
			<tr>
				<td class="header_logo_small"><a class="header_logo_small" href="#"></a></td>
				<td class="header_announce">
					<marquee style="letter-spacing:1px;marquee-speed:slow;">
						Nilai <strong>UTS</strong> Semester Gasal Periode 2012-2013 sudah keluar *sebagian. 
						Jika anda menemukan Bug / Kritik / Saran, silahkan Laporkan kepada ICT Sesegera mungkin. 
						Terima Kasih.
					</marquee>
				</td>
				<td class="header_user_name"><a class="header_user_name_a" href="#"><?php echo (strlen($_username) < 15 ? ucwords(strtolower($_username)) : ucwords(strtolower(substr($_username,0,15)))."..."); ?></a></td>
				<td class="header_user_photo">
					<a class="header_user_photo_a" href="#">
						<img class="header_user_photo_img" src="images/people/default.gif">
					</a>
				</td>
			</tr>
		</table>
	</header>
	<table class="board">
		<tr>
			<td class="sidebar">
				<div id="navigation">
					<ul class="top-level">
						<?php
							$basename_url = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
							foreach($_level_settings->menu as $foreach){
								if ($basename_url == $foreach->url){$clicked = 'class="clicked"';}else{$clicked = '';}
								echo '<li><a href="'.$foreach->url.'" '.$clicked.'>'.$foreach->nama.'</a></li>';
							}
						?>
					</ul>
				</div> 
			</td>
			<td class="bigbox">
				<div class="banner"></div>
				<div class="content letter-spacing"><br \>
					<h1>Penawaran Mata Kuliah</h1><br \>
					<h2>informasi...</h2><br \>					
					<div align="center">
						<table class="data head">
							<tr>
								<td width="15%">Sesi / Periode</td><td width="2%">:</td><td width="35%"><?php echo $_semester.' - '.$_tahun_ajaran?></td>
								<td>Menyortir</td><td width="2%">:</td>
								<td>
									<select name="sort_penawaran" onchange="document.location.href='<?php echo $basename_url; ?>?pilah='+this.value;">
									  <option value="">-- Pilih --</option>
									  <option value="all">Semua Jurusan !</option>
									  <option value="111">Management</option>
									  <option value="112">Akuntansi</option>
									  <option value="212">Arsitektur</option>
									  <option value="311">Informatika</option>
									  <option value="611">Bahasa Tionghoa</option>
									  <option value="614">Bahasa Inggris</option>
									</select>
								</td>
							</tr>
						</table>
						<br />
						<table class="data body small">
						<thead>
							<tr>
								<th>Kode</th><th>Mata Kuliah</th><th>Jurusan</th><th>Dosen</th>
								<th>Hari</th><th width="16%">Pukul</th>
							</tr>
						</thead>
						<tbody>							
						<?php
							if(!empty($_GET['pilah'])){
								if($_GET['pilah'] == 'all') {$_GET['pilah'] = "";}
								$count = 1; //using odd php for css2 browser and less
								$sql = "SELECT penawaran.kodemk, nama, semester, jurusan, dosen, sesi, periode, hari, mulaipukul, selesaipukul 
										FROM penawaran, mk WHERE penawaran.kodemk = mk.kodemk AND jurusan LIKE :jurusan AND periode LIKE :periode
										ORDER BY periode DESC, jurusan ASC, penawaran.kodemk ASC ";
								$stmt = $pdo->prepare($sql);
								$stmt->execute(array(':jurusan' => '%'.$_GET['pilah'].'%' 
													,':periode' => $_tahun_ajaran
													)); //reg jurusan dari protect1.php
								while($_data = $stmt->fetch(PDO::FETCH_OBJ)){ //fetch data to stdclass object
									$_data->url = "view_mk.php?kodemk=".$_data->kodemk;
									?>
										<tr onclick="document.location.href='<?php echo $_data->url;?>';" <?php echo ( ($count % 2) == 0 ? 'class="odd"' : ''); ?>>
											<td class="center"><a id="block" href="<?php echo $_data->url;?>"><?php echo $_data->kodemk; ?></a></td>														
											<td align="left"><a id="block" href="<?php echo $_data->url;?>"><?php echo $_data->nama; ?> <span class="sign <?php echo $function_html->getWarnaSemester($_data->semester); ?> border"><?php echo $_data->semester; ?></span></a></td>
											<td class="center"><a id="block" href="<?php echo $_data->url;?>"><?php echo $_data->jurusan; ?></a></td>
											<td class="center"><a id="block" href="<?php echo $_data->url;?>"><?php echo $_data->dosen; ?></a></td>
											<td class="center"><a id="block" href="<?php echo $_data->url;?>"><?php echo $_data->hari; ?></a></td>
											<td class="center"><a id="block" href="<?php echo $_data->url;?>"><?php echo $_data->mulaipukul."-".$_data->selesaipukul; ?></a></td>
										</tr>
									<?php
									$count++;
								}
							}else{
								?>
									<tr <?php echo ( ($count % 2) == 0 ? 'class="odd"' : ''); ?>>
										<td class="center"><a id="block" href="<?php echo $_data->url;?>"><?php echo $_data->kodemk; ?></a></td>														
										<td align="left"><a id="block" href="<?php echo $_data->url;?>"><?php echo $_data->nama; ?></a></td>
										<td class="center"><a id="block" href="<?php echo $_data->url;?>"><?php echo $_data->jurusan; ?></a></td>
										<td class="center"><a id="block" href="<?php echo $_data->url;?>"><?php echo $_data->dosen; ?></a></td>
										<td class="center"><a id="block" href="<?php echo $_data->url;?>"><?php echo $_data->hari; ?></a></td>
										<td class="center"><a id="block" href="<?php echo $_data->url;?>"><?php echo $_data->mulaipukul."-".$_data->selesaipukul; ?></a></td>
									</tr>
								<?php
								$count = 0;
							}
							?>
						</tbody>
						<tfoot>
							<tr>
								<td>TOTAL</td><td style="text-align:left;"><span class="sign black big border"><?php echo $count; ?></span> Mata Kuliah</td><td colspan="5"></td>
							</tr>
						</tfoot>
						</table>
						<br \>
						<table class="data foot">
							<tbody>
								<tr>
								<tr><th width="25%">Nilai IPS terakhir </td><td>&nbsp;<?php echo $_data->ips; ?></td></tr>
								<tr><th>Limit SKS anda</td><td>&nbsp;<?php echo $limit_sks; ?>  SKS</td></tr>
								<tr><th>Toleransi SKS anda</td><td>&nbsp;<?php echo $_data->toleransi; ?> SKS</td></tr>
								<tr><th>Sisa Limit SKS anda</td><td>&nbsp;<?php echo $limit_sks + $toleransi - $_data2->sks_krs; ?> SKS</td></tr>
							</tbody>
						</table>
					</div>
					<div style="padding-bottom:50px;"></div>
				</div>
			</td>
		</tr>
	</table>
	<footer id="main">
	  <div><a href="http://www.widyakartika.ac.id/perpustakaan">Perpustakaan Online</a> | <a href="http://krs.widyakartika.ac.id/">KRS Online</a></div>
	  <div>Copyright &copy; 2012. <a href="http://www.widyakartika.ac.id">Universitas Widya Kartika</a> & <a href="#">Labkom ICT</a> - All rights reserved</div>
		<?php
			$_finish_timer = get_microtime();
			echo 'Page generated in '.round(($_finish_timer - $_start_timer), 4).' seconds.';
		?>
	</footer>
</body>
